package cn.xej.demo.config;

import cn.xej.demo.Car;
import cn.xej.demo.service.UserService;
import cn.xej.demo.service.impl.User2ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author alicat.xu
 * @Date 2021/11/3 3:10 下午
 */
@Configuration
public class UserServiceConfig {
//    static {
//        System.out.println("UserServiceConfig");
//    }


    @Bean
    public UserServiceFactory initsUserServiceMap(){
        UserServiceFactory userServiceFactory = new UserServiceFactory();
        return userServiceFactory;
    }

    @Bean
    public UserServiceFactory initUserServiceMap(List<Integer> userServices){
        UserServiceFactory userServiceFactory = new UserServiceFactory();
        for (UserService userService : userServices) {
            userServiceFactory.register(userService.getType(),userService);
        }
        userServiceFactory.getAll();
        return userServiceFactory;
    }
}
